import os
import cv2


img_dir = r"H:\data\cell\RCF\edge_inv"
w_dir = r"H:\data\cell\RCF\edge"
names = os.listdir(img_dir)
for name in names:
    img_path = os.path.join(img_dir, name)
    print(img_path)
    gray = cv2.imread(img_path, 0)
    ret, thresh2 = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY_INV)
    w_path = os.path.join(w_dir, name)
    cv2.imwrite(w_path, thresh2)







